let Sequelize = require("sequelize");

module.exports = function (sequelize, DataTypes) {
	let Corp = sequelize.define("Corp", {		
		corp_no: { type: Sequelize.STRING,primaryKey: true},
		appid: { type: Sequelize.STRING },
		wxaappid: { type: Sequelize.STRING },
		corp_name: { type: Sequelize.STRING },
		remark: { type: Sequelize.TEXT }
	}, {
		tableName: 'uc_corp',
		comment: '公司基础表',
		underscored: true,
		'timestamps': true,
		'paranoid': true,
		'createdAt': 'created_at',
		'updatedAt': 'updated_at',
		'deletedAt': 'deleted_at',
		classMethods: {
			associate: function (models) {
				/*
				Corp.belongsTo(models.User, {
					onDelete: "CASCADE",
					foreignKey: {
						name : 'corpid',
						allowNull: true
					}
				});*/
				//models.User.hasMany(Corp,{foreignKey : 'from_uid',targetKey:'id'})
			}
		},
		instanceMethods: {
			toJSON: function () {
				let values = Object.assign({}, this.get());
				return values;
			}
		}
	});
	return Corp;
};
